package com.haofengsoft.scce.ui.fragment;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.haofengsoft.platform.companent.scrollview.PagerSlidingLineTabStrip;
import com.haofengsoft.scce.R;
import com.haofengsoft.scce.adapter.quotations.QuotationsMenuAdapter;
import com.haofengsoft.scce.adapter.quotations.QuotationsMenuModel;
import com.haofengsoft.scce.ui.quotations.BeiJingFragment;
import com.haofengsoft.scce.ui.quotations.NanJingFragment;
import com.haofengsoft.scce.ui.quotations.ShangHaiFragment;
import com.haofengsoft.scce.ui.quotations.ZhongNanFragment;

/**
 * 行情
 * 
 * @author zhj
 * 
 */
public class QuotationsFragment extends BaseFragment {

	private PagerSlidingLineTabStrip quotationsTabPsts;
	private ViewPager quotationsVp;

	private QuotationsMenuAdapter pagerAdapter = null;
	private List<QuotationsMenuModel> menuModelList;
	private Context context;

	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.main_quotations, container, false);
		view.setOnTouchListener(new DontSpillOnTouchListener());

		quotationsTabPsts = (PagerSlidingLineTabStrip) view.findViewById(R.id.quotations_menu_tab_psts);
		quotationsTabPsts.setTextColorResource(R.color.common_default_tv_nor);
		quotationsVp = (ViewPager) view.findViewById(R.id.quotations_body_vp);
		quotationsTabPsts.setIndicatorColorResource(R.color.common_btn_nor);
		configMenu();
		pagerAdapter = new QuotationsMenuAdapter(getChildFragmentManager(), menuModelList);
		quotationsVp.setAdapter(pagerAdapter);
		quotationsTabPsts.setViewPager(quotationsVp);
		return view;
	}

	private void configMenu() {
		menuModelList = new ArrayList<QuotationsMenuModel>();
		QuotationsMenuModel shanghaiModel = new QuotationsMenuModel();
		shanghaiModel.setTitle("上海");
		shanghaiModel.setFragment(new ShangHaiFragment());
		menuModelList.add(0, shanghaiModel);

		QuotationsMenuModel beijingModel = new QuotationsMenuModel();
		beijingModel.setTitle("北京");
		beijingModel.setFragment(new BeiJingFragment());
		menuModelList.add(1, beijingModel);

		QuotationsMenuModel nanjingModel = new QuotationsMenuModel();
		nanjingModel.setTitle("南京");
		nanjingModel.setFragment(new NanJingFragment());
		menuModelList.add(2, nanjingModel);

		QuotationsMenuModel zhongnanModel = new QuotationsMenuModel();
		zhongnanModel.setTitle("中南");
		zhongnanModel.setFragment(new ZhongNanFragment());
		menuModelList.add(3, zhongnanModel);
	}

	@Override
	protected void lazyLoad() {

	}
}
